﻿''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' NOTICE                                                                             '
' -------                                                                            '
' Portions of this source code were taken from the Windows 7 Taskbar Single Instance '
' recipe, which can be found at the following URL:                                   '
' http://code.msdn.microsoft.com/Windows-7-Taskbar-Single-4120eafd                   '
'                                                                                    '
' The Windows 7 Taskbar Single Instance recipe is released under the Apache License, '
' version 2.0. This license is located at the following URL:                         '
' http://www.apache.org/licenses/LICENSE-2.0                                         '
'                                                                                    '
' This program also uses James Newton-King's Json.NET library, which can be found at '
' http://json.codeplex.com/                                                          '
'                                                                                    '
' Json.NET is licensed under the MIT license, which as of 4/11/2011, can be found at '
' http://json.codeplex.com/license                                                   '
'                                                                                    '
' This source code itself is licensed under the MIT license, which can be found at   '
' http://collegiate.codeplex.com/license                                             '
'                                                                                    '
' All mentioned licenses can be found in the Licenses folder provided with this code.'
'                                                                                    '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Imports System
Imports System.Windows
Imports WindowsRecipes.TaskbarSingleInstance
Imports WindowsRecipes.TaskbarSingleInstance.Wpf

Namespace Collegiate
    Module Program
        <STAThread()> _
        Sub Main()
            Using manager As SingleInstanceManager = SingleInstanceManager.Initialize(GetSingleInstanceManagerSetup())
                Dim app As New App()
                app.InitializeComponent()
                app.Run()
            End Using
        End Sub

        Private Function GetSingleInstanceManagerSetup() As SingleInstanceManagerSetup
            ' Collegiates GUID = {735FF991-61AD-4541-BC46-025E5C87D84D}
            Return New SingleInstanceManagerSetup("{735FF991-61AD-4541-BC46-025E5C87D84D}") With _
            { _
                .ArgumentsHandler = Function(args As String()) DirectCast(Application.Current, App).ProcessCommandLineArgs(args), _
                .ArgumentsHandlerInvoker = New ApplicationDispatcherInvoker(), _
                .DelivaryFailureNotification = Function(ex) MessageBox.Show(ex.Message, "An error occured") _
            }
        End Function
    End Module
End Namespace
